import 'package:acaleph/bak/views/call.dart';
import 'package:acaleph/bak/views/form_demo.dart';
import 'package:acaleph/bak/views/image_picker.dart';
import 'package:acaleph/bak/views/preferences.dart';
import 'package:acaleph/bak/views/share.dart';
import 'package:acaleph/pages/Login_page.dart';
import 'package:acaleph/utils/route_util.dart';
import 'package:flutter/material.dart';
import 'package:acaleph/pages/test_list2_page.dart';
import 'package:acaleph/bak/views/message.dart';

class DemoMenu extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    // TODO: implement createState
    return new DemoMenuState();
  }
}

class DemoMenuState extends State<DemoMenu> {
  Widget _buildButton(String title) {
    return GestureDetector(
      // When the child is tapped, show a snackbar
        onTap: () {
          if(title == '详情'){
            RouteUtil.route2Detail(context, '2728322447475712');
          } else if(title == '列表'){
            RouteUtil.route2List(context);
          } else if(title == 'web网页'){
            RouteUtil.route2Web(context, "web网页", "http://www.baidu.com");
          } else if(title == '登录页面'){
            RouteUtil.route2Form(context, new LoginPage());
          } else if(title == 'CALL'){
            RouteUtil.route2Form(context, new Call());
          } else if(title == '照相'){
            RouteUtil.route2Form(context, new TakePhoto());
          } else if(title == '分享'){
            RouteUtil.route2Form(context, new ShareDemo());
          }else if(title == '质感跳转'){
            RouteUtil.route2M(context, new ShareDemo());
          }else if(title == '表单填写'){
            RouteUtil.route2M(context, new TextFormFieldDemo());
          }else if(title == '缓存'){
            RouteUtil.route2M(context, new SharedPreferencesDemo());
          }else if(title == '表单'){
            RouteUtil.route2M(context, new FormDemo());
          }
        },
      // Our Custom Button!
      child:Container(
        margin: new EdgeInsets.all(10.0),
        padding: new EdgeInsets.all(10.0),
        alignment: Alignment.center,
        decoration: new BoxDecoration(
          color: Colors.blue[400],
          borderRadius: new BorderRadius.all(
            //让矩形四个角都变成圆角
            const Radius.circular(8.0),
          ),
          // 阴影
          boxShadow: <BoxShadow>[
            new BoxShadow(
              color: Colors.teal[100],
              offset: new Offset(0.0, 5.0),
              blurRadius: 8.0,
            ),
            new BoxShadow(
              color: Colors.grey,
              offset: new Offset(0.0, 6.0),
              blurRadius: 8.0,
            ),
          ],
        ),
        child: new Container(
          child: new Text(title, style: new TextStyle(color: Colors.white)),
          color: Colors.blue[400],
        ),
      )
    );

  }

  @override
  Widget build(BuildContext context) {

    return new Scaffold(
      body: ListView(
        padding: const EdgeInsets.all(8.0),
        children: <Widget>[Center(
          child: new Column(children: <Widget>[
//            _buildButton('详情'),
            _buildButton('列表'),
            _buildButton('web网页'),
            _buildButton('登录页面'),
            _buildButton('CALL'),
            _buildButton('照相'),
            _buildButton('分享'),
            _buildButton('质感跳转'),
            _buildButton('表单填写'),
            _buildButton('缓存'),
//            _buildButton('表单'),
          ]),
        )],
      ),
    );
  }
}
